package com.gf.gf_data.controller;

import com.gf.gf_data.dto.BaseResult;
import org.springframework.boot.autoconfigure.web.ErrorController;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * 404 异常控制处理器
 * (@RestControllerAdvice 的补充)
 *
 * Created by Eternal_L on 2017/12/22.
 */
@RestController
public class FinalExceptionController implements ErrorController {

    // 采用spring-boot 默认的映射/error
    private static final String DEFAULT_ERROR_VIEW = "/error";

    @RequestMapping(value = "/error", produces = MediaType.APPLICATION_JSON_VALUE)
    public BaseResult error() {
        // TODO: 错误处理逻辑
        return new BaseResult(false, 404, "Please check the URL to ensure that the path is correct!");
    }

    @Override
    public String getErrorPath() {
        return DEFAULT_ERROR_VIEW;
    }
}
